package com.fbli.controller;

import com.fbli.entity.Result;
import com.fbli.pojo.Feedback;
import com.fbli.service.FeedbackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("/feedback")
public class FeedbackController {
    @Autowired
    private FeedbackService feedbackService;
    @RequestMapping("/insert")
    public Result insertFeedback(@RequestBody Feedback feedback){

        try {
            if (feedback.getContent()!=null&&feedback.getContent().length()>0){
                feedbackService.insertFeedback(feedback);
                return new Result(true,"反馈成功");
            }else {
                return new Result(false,"内容不能为空");
            }

        }catch (Exception e){
            e.printStackTrace();
            return new Result(false,"反馈失败");
        }


    }
}
